package me.zk.practice1.hw;

import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * @author zhangkai
 * @date 2023/8/7 14:22
 */
public class HWBJ77 {
    //64:2,128:1,32:4,1:128
    //50,36,64,128,127
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String heapStr = scanner.nextLine();

        String string = scanner.nextLine();

        Map<Integer,Integer> map = new TreeMap<>(Comparator.naturalOrder());

        String[] heapArr = heapStr.split(",");
        for(String s : heapArr) {
            String[] t = s.split(":");
            map.put(Integer.parseInt(t[0]),Integer.parseInt(t[1]));
        }
        String[] ss = string.split(",");

        for (String s: ss) {
            boolean used = false;
            for (Integer i : map.keySet()) {
                if ( i>=Integer.parseInt(s)  && map.get(i)>0) {
                    map.put(i,map.get(i)-1);
                    used = true;
                    break;
                }
            }
            System.out.println(used);
        }

    }
}
